package com.jianyun.jyzs.utils;

import android.content.Context;

/**
 * Created by mlli on 2017/12/7.
 * 初始化一些数据
 */

public class BaseDataInit {
    public static void initWorkType(Context context,String enterpriseCode){
        //getIssue(context,enterpriseCode);
       // getQualityIssue(context,enterpriseCode);
    }

    /*private static void getQualityIssue(final Context context, String enterpriseCode) {
        Api api = RetrofitHelper.builderbch().create(Api.class);
        final QualityIssueDao dao = new QualityIssueDao(context);
        HashMap<String, String> map = new HashMap<>();
        map.put("enterpriseCode",enterpriseCode);
//        map.put("lateId","0");
        RceLog.d("lml",map.toString());
        api.getQualityIssueType(map).observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new CustomCallback<IssueTypeResponse>() {
                    @Override
                    protected void onResponse(IssueTypeResponse response) {
                        RceLog.d("lml",response.toString());
                        if (response.isResult()){
                            dao.delAll();
                            List<IssueTypeResponse.Issuety> list = response.getList();
                            for (IssueTypeResponse.Issuety ii:list) {
                                dao.insert(ii);
                            }
                        }else {

                        }

                    }

                    @Override
                    protected void onException(String msg) {
                        ToastUtil.showNoWaitToast(context,msg);
                    }
                });
    }

    private static void getIssue(final Context context, String enterpriseCode) {
        final SecurityIssueTypeDao dao = new SecurityIssueTypeDao(context);
        Api api = RetrofitHelper.builderbch().create(Api.class);
        HashMap<String, String> map = new HashMap<>();
        map.put("enterpriseCode",enterpriseCode);
//        map.put("lateId","0");
        RceLog.d("lml",map.toString());
        api.safeIssurType(map).observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new CustomCallback<SafeIssueType>() {
                    @Override
                    protected void onResponse(SafeIssueType response) {
                        if (response.isResult()){
                            dao.delAll();
                            List<SafeIssueType.SafeIssue> issueList = response.getList();
                            for (SafeIssueType.SafeIssue ss:issueList
                                    ) {
                                dao.insert(ss);
                            }
                        }else {
                            ToastUtil.showNoWaitToast(context,response.getMessage());
                        }
                    }

                    @Override
                    protected void onException(String msg) {
                        ToastUtil.showNoWaitToast(context,msg);
                    }
                });
    }*/
}
